package com.zzyl.controller;

import com.zzyl.base.PageResponse;
import com.zzyl.base.ResponseResult;
import com.zzyl.dto.NursingLevelDto;
import com.zzyl.service.NursingLevelService;
import com.zzyl.vo.NursingLevelVo;
import com.zzyl.vo.NursingPlanVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Description NursingLevelController
 * @Author liangDong
 * @Date 2025-05-09  14:08
 */
@RestController
@RequestMapping("/nursingLevel")
public class NursingLevelController extends BaseController{
    @Autowired
    private NursingLevelService nursingLevelService;

    @GetMapping("/listAll")
    public ResponseResult listAll(){
        List<NursingLevelVo> nursingLevelVoList = nursingLevelService.listAll();
        return success(nursingLevelVoList);
    }

    @PostMapping("/insert")
    public ResponseResult addNursingLevel(@RequestBody NursingLevelDto nursingLevelDto){
        nursingLevelService.addNursingLevel(nursingLevelDto);
        return success();
    }

    @GetMapping("/listByPage")
    public ResponseResult<PageResponse<NursingLevelVo>> page(
            @RequestParam(required = false) String name,
            @RequestParam(required = false) Integer status,
            @RequestParam(defaultValue = "1") Integer pageNum,
            @RequestParam(defaultValue = "10") Integer pageSize
    ){
        PageResponse<NursingLevelVo> nursingLevelVoList = nursingLevelService.page(name,status,pageNum,pageSize);
        return success(nursingLevelVoList);
    }

    @GetMapping("/{id}")
    public ResponseResult getNursingLevelById(@PathVariable Integer id){
        NursingLevelVo nursingLevelVo = nursingLevelService.getById(id);
        return success(nursingLevelVo);
    }

    @PutMapping("/update")
    public ResponseResult update(@RequestBody NursingLevelDto nursingLevelDto){
        nursingLevelService.update(nursingLevelDto);
        return success();
    }

    @DeleteMapping("/delete/{id}")
    public ResponseResult delete(@PathVariable Integer id){
        nursingLevelService.delete(id);
        return success();
    }

    @PutMapping("/{id}/status/{status}")
    public ResponseResult updateStatus(@PathVariable Integer id , @PathVariable Integer status){
        nursingLevelService.updateStatus(id,status);
        return success();
    }
}
